/// <reference path="../../Resources/js/jquery/jquery.debug.js" />

Type.registerNamespace("BM");

// RadioButtonListValueHandler object

BM.RadioButtonListValueHandler = function(leafItem) {
    BM.RadioButtonListValueHandler.initializeBase(this, [leafItem]);
}

BM.RadioButtonListValueHandler.prototype = {    
    
    getInputsPath: function() {
        return " input[type = radio]";        
    },               
    
    getControlValue: function() {
        var inputs = this.getInputs();
        for(var i = 0; i < inputs.length; i++) {
            if (inputs[i].checked) {
                return inputs[i].value;
                break;
            } 
        }          
    },

    setControlValue: function(value) {
        var inputs = this.getInputs();
        for(var i = 0; i < inputs.length; i++) {
            if (inputs[i].value == value) {
                inputs[i].checked = true;
            } 
        }
    }      
}

BM.ValueHandler['RadioButtonListValueHandler'] = BM.RadioButtonListValueHandler;
BM.RadioButtonListValueHandler.registerClass("BM.RadioButtonListValueHandler", BM.InputsContainerValueHandler);